#!/bin/bash

TOP_DIR=${PWD}

help()
{
    echo "usage: ./build.sh [PLATFORM]"
	echo "eg: ./build.sh x64"
	echo ""

	for ITEM in `ls configs`;do
		NAME="${ITEM%%.*}"
        if [ "$NAME" == "win64" ];then
			continue
		fi
		echo "${NAME}"
	done
}

build()
{
    BUILD_DIR=build/$1
    mkdir -p ${BUILD_DIR}
    rm -fr ${BUILD_DIR}/*

    cd ${BUILD_DIR}
    cmake -DCMAKE_TOOLCHAIN_FILE=${TOP_DIR}/configs/$1.cmake ${TOP_DIR}
    make

}

main()
{
    if [ $# = 1 ];then
        build $1 
    else
        help 
        exit -1
    fi
}

main "$@"